<%= error_messages_for 'contact' %>
<!-- {:onclick=>"Element.show('edit_tags_form'); Element.hide('last_name');  return false;"} -->


<div class = "box tabular" id="contact_data">     

<script type="text/javascript" charset="utf-8">
	function togglePerson(element) {
		if (element.checked) {
		  $('#person_data').hide();
		  $('#job_title').firstChild.innerHTML='<%= l(:field_company_field) %>';
		  $('#first_name').firstChild.innerHTML='<%= l(:field_company_name) %>' + '<span class="required"> *</span>';
		  
		} else {
		  $('#person_data').show();
		  $('#job_title').firstChild.innerHTML='<%= l(:field_contact_job_title) %>';
		  $('#first_name').firstChild.innerHTML='<%= l(:field_contact_first_name) %>' + '<span class="required"> *</span>';
		}

	}         
</script>
		
	<p class="avatar" id="watchers">
		<%= avatar_to(@contact, :size => "64", :style => "vertical-align: middle;") %>
		<%= link_to image_tag('delete.png'), {:controller => 'attachments', :action => 'destroy', :id => @contact.avatar},
	                                         :confirm => l(:text_are_you_sure),
	                                         :method => :delete,
	                                         :class => 'delete',
											 :style => "vertical-align: middle;",
	                                         :title => l(:button_delete) unless @contact.avatar.blank? %>
	</p>    
	<p><%= label_tag l(:field_contact_avatar) %> <%= file_field_tag 'contact_avatar[file]', :size => 30, :id => nil  -%> </p>
	<p><%= f.check_box(:is_company, :label => l(:field_contact_is_company), :onclick => "togglePerson(this)" ) %></p>
	<p id="first_name"><%= f.text_field :first_name, :label => !@contact.is_company ? l(:field_contact_first_name) : l(:field_company_name), :required => true, :size => 80%></p>    
	<% if @contact.is_company %>
	<div id="person_data" style="display: none;">
	<% else %>
	<div id="person_data">
	<% end %>
		<p><%= f.text_field 'middle_name', :label=>l(:field_contact_middle_name) %></p>
		<p><%= f.text_field :last_name, :label=>l(:field_contact_last_name), :id => 'contact_last_name' %></p>
		<p><%= f.text_field 'company', :label=>l(:field_contact_company) -%></p> 
		<p><%= f.text_field :birthday, :size => 12 %><%= calendar_for('contact_birthday') %> </p>   
	</div>
	<p id="job_title"><%= f.text_field :job_title, :label => !@contact.is_company ? l(:field_contact_job_title) : l(:field_company_field) %></p>
	<p><%= f.text_area 'address', :label=>l(:field_contact_address), :rows => 5 -%></p>

	<div id="phones_fields"> 
		<p>
			<%= f.text_field :phone, :label=>l(:field_contact_phone), :size => 80 -%>
			<br>
			<em><%= l(:text_comma_separated) %></em>                                                       
		 </p>  
	</div>   
			
	<p>
		<%= f.text_field 'email', :label=>l(:field_contact_email), :size => 80 -%>
		<br>
		<em><%= l(:text_comma_separated) %></em>
	</p>     

	<p><%= f.text_field 'website', :label=>l(:field_contact_website) -%></p>
	<p><%= f.text_field 'skype_name', :label=>l(:field_contact_skype) -%></p> 
	<p class  = "notes"><%= f.text_area :background , :cols => 80, :rows => 8, :class => 'wiki-edit', :label=>l(:field_contact_background)  %></p>
	<%= wikitoolbar_for 'contact_background' %>
	
	<p>
		<%= label_tag l(:label_tags_plural) %> 
		<%= render :partial => "contacts_tags/tags_form" %> 
	</p>

  	<% if @project %>
		<p><%= f.select :assigned_to_id, (@project.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true, :label => l(:label_assigned_to) %></p> 
	<% end %> 

 
</div>    




